﻿#include "reqclientthread.h"

ReqClientThread::ReqClientThread()
{

}

void ReqClientThread::run()
{

    std::string url = QString("tcp://" + this->ip + ":" + QString::number(this->port)).toStdString();
    QString msg = buildLogoutMsg();
    std::string message = msg.toStdString();
    qDebug() << url.c_str() << ":" << msg << endl;
    req_zmq(url, message, &client_message_call_back);
    recordTime = QTime::currentTime();
}




QString ReqClientThread::buildLoginMsg()
{
    QJsonObject data;
    data.insert("deviceNo", "deviceNo");
    data.insert("expireTime", duration);
    data.insert("tableId", "e295094e6c3b4f599b11ad4d15651ea4");
    data.insert("memberId", "userId");
    data.insert("model", "A");
    data.insert("role", "c");
    data.insert("order", "lockTable");
    QJsonDocument document;
    document.setObject(data);
    QByteArray byte_array = document.toJson(QJsonDocument::Compact);
    return byte_array;
}

QString ReqClientThread::buildLogoutMsg()
{
    QJsonObject data;
    data.insert("batchNo", "B_N_202012018636ff27a963587");
    data.insert("tableId", "2a86f665b0ec44c1b7ad3546e8d46455");
    data.insert("order", "unLockTable");
    QJsonDocument document;
    document.setObject(data);
    QByteArray byte_array = document.toJson(QJsonDocument::Compact);
    return byte_array;
}

QString ReqClientThread::buildStopMsg()
{
    //return QString("%1:%2").arg("TRAINING_STOP").arg("SCORE_LOADING");
    return QString("%1:%2").arg("INSTANT").arg("UpperTrunkBendS");
}
